﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint;

namespace ITSP.SharePoint.CacheRefresh.Interfaces
{
    /// <summary>
    /// Interface for the Cache Configuration Item
    /// </summary>
    public interface ICacheConfigItem
    {
        int ListItemId { get; set; }
        string CacheKey { get; set; }
        string Description { get; set; }
        string CacheDependencyPath { get; set; }
        int CacheFrequency { get; set; }
        bool CacheEnabled { get; set; }
        bool Exists { get; set; }
    }

    /// <summary>
    /// Interface for the Cache Configuration Repository
    /// </summary>
    public interface ICacheConfigurationRepository : IDisposable
    {
        /// <summary>
        /// Get List of Cache Configuration Items
        /// </summary>
        /// <returns></returns>
        IList<ICacheConfigItem> GetAll();

        /// <summary>
        /// Gets a Cache Configuration Item
        /// </summary>
        /// <returns></returns>
        ICacheConfigItem Get(string cacheKey);

        /// <summary>
        /// Get the SharePoint List Item using the cacheKey.
        /// </summary>
        /// <param name="cacheKey"></param>
        /// <returns></returns>
        SPListItem GetListItem(string cacheKey);

        /// <summary>
        /// Adds a Cache Configuration Item to the Cache Configuration List.
        /// </summary>
        /// <param name="cacheKey"></param>
        /// <param name="description"></param>
        /// <param name="cacheDependencyLocation"></param>
        /// <param name="cacheFrequency"></param>
        /// <param name="cacheEnabled"></param>
        /// <returns></returns>
        ICacheConfigItem Add(string cacheKey, string description, string cacheDependencyLocation, int cacheFrequency, bool cacheEnabled);

        /// <summary>
        /// Deletes a Cache Configuration Item
        /// </summary>
        /// <returns></returns>
        bool Delete(string cacheKey);

        /// <summary>
        /// Updates SharePoint with the Cache Configuration Item information.
        /// </summary>
        /// <returns></returns>
        ICacheConfigItem Update(ICacheConfigItem configItem);
    }
}
